import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

// https://vitejs.dev/config/
export default({mode})=> defineConfig({
  plugins: [vue()],
  resolve:{
    alias:{
      '~':path.resolve(__dirname,'../'),  //～代表根目录下的别名
      '@':path.resolve(__dirname,'src')  //@代表src目录下的别名
    },
    extensions:['.vue','.js','jsx','.json']
  },
  // base:mode=='development'?'./':(mode=='beta'?'//s.baidu.com/beta/xxx':'//s.baidu.com/release/xxx'),
  base:'./',
  
  server:{
    host:'0.0.0.0',
    port:4000,
    open:true,
    cors:true,
    proxy:{
      '/api':{
        target: 'http://backend-api-02.newbee.ltd/manage-api/v1', // 凡是遇到 /api 路径的请求，都映射到 target 属性
        changeOrigin:true,
        rewrite:path=>path.replace(/^\/api/,'')  //重写api为空，就是去掉它
      }
    }
  }
  
})
